package com.gitee.wsl.compose.state.ext

import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.autoSaver
import androidx.compose.runtime.saveable.rememberSaveable
import com.gitee.wsl.compose.state.S


@Composable
fun <T> S.saveState(init:T) = rememberSaveable {
    mutableStateOf(init)
}

@Composable
fun <T : Any> S.saveState(vararg inputs: Any?,
                          saver: Saver<T, out Any> = autoSaver(),
                          key: String? = null,
                          init: () -> T) = rememberSaveable(inputs, saver, key, init=init)

